from urllib import request

# 最简单的GET请求，获取到响应
# urllib.request.urlopen(url, data=None, [timeout,]*, cafile=None, capath=None, cadefault=False, context=None)
response = request.urlopen('https://www.python.org')

# 输出响应内容，并转码utf-8
print(response.read().decode('utf-8'))
# print(type(response))

# 响应状态码
print(response.status)

# 获取所有响应头
print(response.getheaders())

# 获取某一个响应头
print(response.getheader('content-type'))